﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Solution.Business.Component;
using Solution.Business.Entities;
using Solution.Data;
using MvcPaging;

namespace Solution.UI.Web.Controllers
{
    public class NewsController : Controller
    {
        private SolutionEntities db = new SolutionEntities();
        private const int DefaultPageSize = 12;
        private IList<News> list;
        //
        // GET: /News/

        //public NewsController()
        //{
        //    InitializeProducts();
        //}

        //private void InitializeProducts()
        //{
        //    // Create a list of products. 50% of them are in the Shoes category, 25% in the Electronics 
        //    // category and 25% in the Food category.
        //    list = Business.Component.NewsComponent.News_GetByTop("1000", "", "");
        //}

        public ActionResult NewsByTransaction(int TrGroup2, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and TrId in (select TrId from [Transaction] where TrGroup2 = '"+ TrGroup2 +"')", "");
            ViewBag.TrGroup2 = TrGroup2;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByProject(int TrId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and TrId = '" + TrId + "'", "");
            ViewBag.TrId = TrId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByLocation(int LId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and LId = '" + LId + "'", "");
            ViewBag.LId = LId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice1(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and Price < 1 and TrId in (select TrId from [Transaction] where TrGroup = 1)", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice2(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 1 and 2) and (TrId in (select TrId from [Transaction] where TrGroup = 1))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice3(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 2 and 5) and (TrId in (select TrId from [Transaction] where TrGroup = 1))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice4(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 5 and 15) and (TrId in (select TrId from [Transaction] where TrGroup = 1))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice5(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 15 and 60) and (TrId in (select TrId from [Transaction] where TrGroup = 1))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice6(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 60 and 120) and (TrId in (select TrId from [Transaction] where TrGroup = 1))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice7(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and Price > 120 and (TrId in (select TrId from [Transaction] where TrGroup = 1))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice8(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and Price < 2 and (TrId in (select TrId from [Transaction] where TrGroup = 2))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice9(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 2 and 5) and (TrId in (select TrId from [Transaction] where TrGroup = 2))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice10(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 5 and 15) and (TrId in (select TrId from [Transaction] where TrGroup = 2))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice11(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 15 and 60) and (TrId in (select TrId from [Transaction] where TrGroup = 2))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice12(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and (Price between 60 and 120) and (TrId in (select TrId from [Transaction] where TrGroup = 2))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByPrice13(int PmId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and PmId = '" + PmId + "' and Price > 120 and (TrId in (select TrId from [Transaction] where TrGroup = 2))", "");
            ViewBag.PmId = PmId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }


        public ActionResult NewsByAcreage1(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and Acreage < 50", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage2(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 50 and 100)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage3(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 100 and 150)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage4(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 150 and 200)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage5(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 200 and 500)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage6(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 500 and 800)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage7(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 800 and 1000)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage8(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 1000 and 1500)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage9(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and (Acreage between 1500 and 2000)", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }

        public ActionResult NewsByAcreage10(int UnId, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            list = Business.Component.NewsComponent.News_GetByTop("1000", "Status = 1 and UnId = '" + UnId + "' and Acreage > 2000", "");
            ViewBag.UnId = UnId;
            return View(this.list.ToPagedList(currentPageIndex, DefaultPageSize));
        }
    }
}
